package com.xinhua.erp.service;

import com.xinhua.erp.pojo.Authority;
import com.xinhua.erp.pojo.ProcessBom;
import com.xinhua.erp.pojo.Result;
import com.xinhua.erp.repo.AuthorityRepo;
import com.xinhua.erp.utils.IdWorker;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import javax.transaction.Transactional;
import java.util.List;

/**
 * @ClassName AuthorityService
 * @Description TODO
 * @Date 2019/12/26 下午10:37
 * @Version 1.0
 **/
@Service
@Transactional
public class AuthorityService {

    @Autowired
    private AuthorityRepo authorityRepo;

    @Autowired
    private IdWorker idWorker;

    public Result findById(long id){

        return Result.OK(authorityRepo.getOne(id));

    }

    public Result findAll(){

        List<Authority> list=authorityRepo.findAll();

        return Result.OK(list);

    }

    public Result deleteById(long id){

        authorityRepo.deleteById(id);

        return Result.OK();

    }

    public Result save(Authority authority){

        authority.setId(idWorker.nextId());

        authorityRepo.save(authority);

        return Result.OK();

    }

    public Result update(Authority authority){

        authorityRepo.save(authority);

        return Result.OK();

    }
}
